package formbeans;

import java.util.ArrayList;
import java.util.List;

import org.mybeans.form.FormBean;

public class LikertQuestionForm extends FormBean {

	private String likertChoice;
	
	public String getLikertChoice() {
		return likertChoice;
	}

	public void setLikertChoice(String likertChoice) {
		this.likertChoice = likertChoice;
	}
	
	public List<String> checkLikertQuestionFormErrors(){
		List<String> errors = new ArrayList<String>();
		
		if (isEmpty(likertChoice)) {
			errors.add("Please choose an answer");
			return errors;
		}
		if (!(likertChoice.equals("1") || likertChoice.equals("2") || likertChoice.equals("3")
				|| likertChoice.equals("4") || likertChoice.equals("5") || likertChoice.equals("6") || likertChoice.equals("7"))) {
			errors.add("Invalid choice");
		}
		
		return errors;
	}
	
	private boolean isEmpty(String str) {
		return (str == null || str.length() == 0);
	}
}